﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ITProject.Domain;

namespace ITProject.WebUI.Models
{
    public class PriorityViewModel
    {
        public List<SelectListItem> Priorities { get; set; }

        public const string High = "Wysoki";
        public const string Normal = "Normalny";
        public const string Low = "Niski";

        public PriorityViewModel()
        {
            Priorities = new List<SelectListItem>();
            Priorities.Add(new SelectListItem { Text = Normal });
            Priorities.Add(new SelectListItem { Text=High });
            Priorities.Add(new SelectListItem { Text = Low });
        }

        public PriorityViewModel(Priority selected)
        {
            Priorities = new List<SelectListItem>();
            switch (selected)
            {
                case Priority.High:
                    Priorities.Add(new SelectListItem { Selected=true, Text = High });
                    Priorities.Add(new SelectListItem { Text = Normal });
                    Priorities.Add(new SelectListItem { Text = Low });
                    break;
                case Priority.Normal:
                    Priorities.Add(new SelectListItem { Selected=true, Text = Normal });
                    Priorities.Add(new SelectListItem { Text = High });
                    Priorities.Add(new SelectListItem { Text = Low });
                    break;
                case Priority.Low:
                    Priorities.Add(new SelectListItem { Selected=true, Text = Low });
                    Priorities.Add(new SelectListItem { Text = Normal });
                    Priorities.Add(new SelectListItem { Text = High });
                    break;
            }
        }

        public static Priority ConvertFromString(string priorityString)
        {
            Priority priority = Priority.Normal;
            switch (priorityString)
            {
                case High:
                    priority = Priority.High;
                    break;
                case Normal:
                    priority = Priority.Normal;
                    break;
                case Low:
                    priority = Priority.Low;
                    break;
            }
            return priority;
        }

        public static string ConvertFromPriority(Priority priority)
        {
            string priorityString = "";
            switch (priority)
            {
                case Priority.Low:
                    priorityString = Low;
                    break;
                case Priority.Normal:
                    priorityString = Normal;
                    break;
                case Priority.High:
                    priorityString = High;
                    break;
            }
            return priorityString;
        }

        public static string ConvertFromByte(byte priority)
        {
            string priorityString = "";
            switch (priority)
            {
                case (byte)Priority.Low:
                    priorityString = Low;
                    break;
                case (byte)Priority.Normal:
                    priorityString = Normal;
                    break;
                case (byte)Priority.High:
                    priorityString = High;
                    break;
            }
            return priorityString;
        }
    }
}